﻿using System;

namespace Demo4.EventDemo
{
    /// <summary>
    /// 事件demo
    /// </summary>
    public class Main
    {
        public static void EventTest()
        {
            Stock stock = new Stock();
            stock.Price = 27.10M;
            stock.PriceChanged += StockPriceChanged;
            stock.Price = 30M;
        }

        static void StockPriceChanged(object send, PriceChangedEventArgs eventArgs)
        {
            if ((eventArgs.NewPrice - eventArgs.LastPrice) / eventArgs.LastPrice > 0.1M)
            {
                Console.WriteLine("Alert, 10% stock price increase!");
            }
        }
    }
}